Mam prosty przykładowy projekt używający TypeScript: https://github.com/unindented/ts-webpack-example
Uruchomienie tsc -p .(z tscwersją 1.8.10) generuje następujące informacje:
app/index.ts(1,21): error TS2307: Cannot find module 'components/counter'.
components/button/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'.
components/button/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'.
components/counter/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'.
components/counter/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'.
components/counter/index.ts(4,27): error TS2307: Cannot find module 'shared/backbone_with_subviews'.
components/counter/index.ts(5,20): error TS2307: Cannot find module 'components/button'.
Narzeka na wszystkie importowane pliki lokalne, takie jak:
import Counter from 'components/counter';
Jeśli zmienię to na ścieżkę względną, to działa, ale nie chcę, ponieważ utrudnia mi to życie podczas przenoszenia plików:
import Counter from '../components/counter';
Plik vscode kodu nie używa ścieżek względnych, ale wszystko działa dla nich dobrze, więc w moim projekcie chyba czegoś brakuje: https://github.com/Microsoft/vscode/blob/0e81224179fbb8f6fda18ca7362d8500a263cfef/src/vs/languages/typescript/common /typescript.ts#L7-L14
Możesz sprawdzić moje repozytorium GitHub, ale na wypadek, gdyby to pomogło, oto tsconfig.jsonplik, którego używam:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"noImplicitAny": false,
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"outDir": "dist"
},
"exclude": [
"dist",
"node_modules"
]
}
Zabawne jest to, że budowanie projektu webpackprzy użyciu ts-loaderdziała dobrze, więc myślę, że to tylko problem z konfiguracją ...
error TS5023: Unknown compiler option 'moduleResolution'.