Skip to content

tsc should give an error if "typings" in package.json is not a string #4828

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
DanielRosenwasser opened this issue Sep 16, 2015 · 5 comments
Closed
Labels
Bug A bug in TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this

Comments

@DanielRosenwasser
Copy link
Member

Courtesy of a long troubleshooting session with @kataras on September 16, 2015.

If you have "typings" in package.json as an array or something instead of a string, we will crash hard:

C:\Users\Makis-PC\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:483
if (path.charCodeAt(0) === 47) {
^
TypeError: path.charCodeAt is not a function
at getRootLength (C:\Users\Makis-PC\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:483:18)
at Object.combinePaths (C:\Users\Makis-PC\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:643:13)
at loadNodeModuleFromDirectory (C:\Users\Makis-PC\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:29439:73)
at loadModuleFromNodeModules (C:\Users\Makis-PC\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:29462:26)
at nodeModuleNameResolver (C:\Users\Makis-PC\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:29405:20)
at resolveModuleName (C:\Users\Makis-PC\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:29385:28)
at C:\Users\Makis-PC\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:29636:115
at Object.map (C:\Users\Makis-PC\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:155:29)
at resolveModuleNamesWorker (C:\Users\Makis-PC\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:29636:67)
at processImportedModules (C:\Users\Makis-PC\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:30013:35)
@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Sep 16, 2015
@mhegazy mhegazy added this to the TypeScript 1.7 milestone Sep 16, 2015
@mhegazy mhegazy modified the milestones: TypeScript 1.7, TypeScript 1.8 Oct 9, 2015
@mhegazy mhegazy added the Help Wanted You can do this label Dec 1, 2015
@mhegazy mhegazy modified the milestones: Community, TypeScript 1.8 Dec 1, 2015
@mhegazy mhegazy added the Good First Issue Well scoped, documented and has the green light label Dec 1, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Dec 1, 2015

PRs are welcomed.

@mhegazy mhegazy closed this as completed in 384ee18 Dec 7, 2015
mhegazy added a commit that referenced this issue Dec 7, 2015
Gracefully handle errors where 'typings' is not a string (fixes #4828)
@mhegazy mhegazy modified the milestones: TypeScript 1.8, Community Dec 7, 2015
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Dec 7, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Dec 7, 2015

thanks @pimterry!

@DanielRosenwasser
Copy link
Member Author

I don't think this was the correct fix. We silently do the wrong thing. We should be giving an error message.

@DanielRosenwasser DanielRosenwasser removed the Fixed A PR has been merged for this issue label Dec 7, 2015
@vladima
Copy link
Contributor

vladima commented Dec 7, 2015

one aspect that will be added in this PR is ability to trace module resolution process so we can record the fact that type of typings is incorrect. Raising errors at this point is bit complicated because currently resolvers simply don't have this ability and it will require changes on the managed side to add it (since module resolution happens on the preprocess step where we don't have the way to report errors and propagate them back).

@mhegazy
Copy link
Contributor

mhegazy commented Dec 7, 2015

@vladima has another validation tool that we should publish, the tool is geared towards package authors, this is where we should report the error.

@mhegazy mhegazy closed this as completed Dec 7, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Bug A bug in TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants