No import error
vehicle.ts:1:41 - error TS2304: Cannot find name 'Vehicle'.
while webpack compiles with no problems (via ts-loader)
VehicleVehicle from vehicle.d.tshttps://github.com/adaamz/ts-node-jasmine-bug
{
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": false,
"alwaysStrict": true,
"esModuleInterop": false,
"module": "commonjs",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"target": "es5"
}
}
Try running ts-node with the --files flag. Tsc loads all matched "files"
and "includes" when it typechecks; ts-node does not for performance
reasons. --files makes it load them like tsc.
On Thu, Jun 11, 2020, 7:43 AM Adam Žurek notifications@github.com wrote:
Expected Behavior
No import error
Actual Behaviorvehicle.ts:1:41 - error TS2304: Cannot find name 'Vehicle'.
Steps to reproduce the problem
- create @types/vehicle.d.ts with defined type Vehicle
- create vehicle.ts with used type Vehicle from vehicle.d.ts
- run ts-node vehicle.ts
Minimal reproduction repository (with github actions integrated)
https://github.com/adaamz/ts-node-jasmine-bug
Specifications
- ts-node version: 8.10.2
- node version: 10, 12, 14
- TypeScript version: 3.9.5
- tsconfig.json:
{
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": false,
"alwaysStrict": true,
"esModuleInterop": false,
"module": "commonjs",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"target": "es5"
}
}
- Operating system and version:
Windows 10, also github actions (ubuntu latest)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/TypeStrong/ts-node/issues/1066, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAC35OA5UNA3KUF3ITY6243RWC7OJANCNFSM4N3KUVGQ
.
I should say "eagerly loads.". Ts-node always loads files when they're ///
On Thu, Jun 11, 2020, 12:43 PM Andrew Bradley cspotcode@gmail.com wrote:
Try running ts-node with the
--filesflag. Tsc loads all matched
"files" and "includes" when it typechecks; ts-node does not for performance
reasons.--filesmakes it load them like tsc.On Thu, Jun 11, 2020, 7:43 AM Adam Žurek notifications@github.com wrote:
Expected Behavior
No import error
Actual Behaviorvehicle.ts:1:41 - error TS2304: Cannot find name 'Vehicle'.
Steps to reproduce the problem
- create @types/vehicle.d.ts with defined type Vehicle
- create vehicle.ts with used type Vehicle from vehicle.d.ts
- run ts-node vehicle.ts
Minimal reproduction repository (with github actions integrated)
https://github.com/adaamz/ts-node-jasmine-bug
Specifications
- ts-node version: 8.10.2
- node version: 10, 12, 14
- TypeScript version: 3.9.5
- tsconfig.json:
{
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": false,
"alwaysStrict": true,
"esModuleInterop": false,
"module": "commonjs",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"target": "es5"
}
}
- Operating system and version:
Windows 10, also github actions (ubuntu latest)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/TypeStrong/ts-node/issues/1066, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAC35OA5UNA3KUF3ITY6243RWC7OJANCNFSM4N3KUVGQ
.
thx for reply!
So how should I change my code that i don't need this "hack"/change of default behavior?
I don't understand what is non-standard in my codebase.
Add a /// On Thu, Jun 11, 2020, 2:04 PM Adam Žurek notifications@github.com wrote: thx for reply! —
So how should I change my code that i don't need this "hack"/change of
default behavior?
I don't understand what is non-standard in my codebase.
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/TypeStrong/ts-node/issues/1066#issuecomment-642844893,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAC35OFCKFC3WKQ7ZMLQFEDRWEMELANCNFSM4N3KUVGQ
.
So the @types directory is problem?
I have there currently only 1 file in my project, so I can move it somewhere else. My use case for this is I want to hide/separate definitions from real app code, because it is really long :-/
To make TSC behave like ts-node, make the files and include arrays in your tsconfig empty except for the entry-point file.
"files": ["vehicle.ts"],
"include": [],
That's what ts-node is doing. Empty arrays, except when a file is require()d, it gets added to the files array.
Then you can experiment to make your setup work the way you want.
Since this is not a ts-node bug, this is all the assistance I have time to provide. ts-node's README, StackOverflow, reddit, and the TypeScript Discord may be able to offer more assistance.
Good luck!
Thanks for tips.
I get to working solution with these changes
@types/Vehicle/index.d.tsDo you have any idea why this works and why is necessery to have tsconfig in project root and manually set these typeRoot directories and have types in this vehicle/index.d.ts (even have types in vehicle.d.ts and import in index.d.ts doesnt work)?
Anyway I will use that --files, much thanks for that, works out-of-box without changing codebase.