Skip to content

Commit 7ba3693

Browse files
config: setup for typescript
Signed-off-by: Arnav Gupta <arnav@codingblocks.com>
1 parent 9b56b37 commit 7ba3693

File tree

5 files changed

+118
-8
lines changed

5 files changed

+118
-8
lines changed

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"license": "MIT",
77
"nativescript": {
88
"id": "in.championswimmer.nsvuets",
9-
"bundle": "webpack",
109
"tns-ios": {
1110
"version": "4.2.0"
1211
},
@@ -15,13 +14,14 @@
1514
}
1615
},
1716
"dependencies": {
18-
"vue-router": "^3.0.1",
19-
"vuex": "^3.0.1",
2017
"nativescript-theme-core": "^1.0.4",
2118
"nativescript-vue": "^2.0.0-alpha.2",
22-
"tns-core-modules": "^4.2.0"
19+
"tns-core-modules": "^4.2.0",
20+
"vue-router": "^3.0.1",
21+
"vuex": "^3.0.1"
2322
},
2423
"devDependencies": {
24+
"@types/node": "^10.7.0",
2525
"babel-traverse": "6.26.0",
2626
"babel-types": "6.26.0",
2727
"babylon": "6.18.0",
@@ -35,10 +35,14 @@
3535
"nativescript-worker-loader": "~0.9.0",
3636
"node-sass": "^4.9.2",
3737
"sass-loader": "^7.1.0",
38+
"ts-loader": "^4.4.2",
39+
"tslib": "^1.9.3",
40+
"typescript": "^3.0.1",
3841
"uglifyjs-webpack-plugin": "~1.2.7",
42+
"vue": "^2.5.17",
3943
"vue-loader": "^15.2.6",
4044
"webpack": "^4.16.4",
4145
"webpack-bundle-analyzer": "~2.13.1",
4246
"webpack-cli": "^3.1.0"
4347
}
44-
}
48+
}

tsconfig.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"compilerOptions": {
3+
/* Basic Options */
4+
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
5+
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
6+
"lib": [
7+
"dom", "es2015"
8+
], /* Specify library files to be included in the compilation. */
9+
// "allowJs": true, /* Allow javascript files to be compiled. */
10+
// "checkJs": true, /* Report errors in .js files. */
11+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
12+
// "declaration": true, /* Generates corresponding '.d.ts' file. */
13+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
14+
"sourceMap": true, /* Generates corresponding '.map' file. */
15+
// "outFile": "./", /* Concatenate and emit output to single file. */
16+
// "outDir": "./", /* Redirect output structure to the directory. */
17+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
18+
// "composite": true, /* Enable project compilation */
19+
// "removeComments": true, /* Do not emit comments to output. */
20+
// "noEmit": true, /* Do not emit outputs. */
21+
"noEmitHelpers": true,
22+
"importHelpers": true, /* Import emit helpers from 'tslib'. */
23+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
24+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
25+
26+
/* Strict Type-Checking Options */
27+
"strict": true, /* Enable all strict type-checking options. */
28+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
29+
// "strictNullChecks": true, /* Enable strict null checks. */
30+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
31+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
32+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
33+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
34+
35+
/* Additional Checks */
36+
// "noUnusedLocals": true, /* Report errors on unused locals. */
37+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
38+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
39+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
40+
41+
/* Module Resolution Options */
42+
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
43+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
44+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
45+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
46+
"typeRoots": [
47+
"types"
48+
], /* List of folders to include type definitions from. */
49+
// "types": [], /* Type declaration files to be included in compilation. */
50+
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
51+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
52+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
53+
54+
/* Source Map Options */
55+
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
56+
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
57+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
58+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
59+
60+
/* Experimental Options */
61+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
62+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
63+
},
64+
"include": [
65+
"app",
66+
"types"
67+
],
68+
"exclude": [
69+
"node_modules",
70+
"platforms"
71+
]
72+
}

types/vue-sfc.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '*.vue' {
2+
import Vue from 'vue'
3+
export default Vue
4+
}

webpack.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module.exports = env => {
7676
globalObject: "global",
7777
},
7878
resolve: {
79-
extensions: [".vue", ".js", ".scss", ".css"],
79+
extensions: [".vue", ".js", ".ts", ".scss", ".css"],
8080
// Resolve {N} system modules from tns-core-modules
8181
modules: [
8282
resolve(__dirname, "node_modules/tns-core-modules"),
@@ -173,6 +173,14 @@ module.exports = env => {
173173
"sass-loader",
174174
],
175175
},
176+
{
177+
test: /\.ts$/,
178+
exclude: /node_modules|vue\/src/,
179+
loader: "ts-loader",
180+
options: {
181+
appendTsSuffixTo: [/\.vue$/]
182+
}
183+
},
176184
{
177185
test: /\.vue$/,
178186
loader: "vue-loader",

yarn.lock

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
version "0.7.0"
3333
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
3434

35+
"@types/node@^10.7.0":
36+
version "10.7.0"
37+
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.7.0.tgz#d384b2c8625414ab2aa18fdf989c288d6a7a8202"
38+
3539
"@vue/component-compiler-utils@^2.0.0":
3640
version "2.1.2"
3741
resolved "https://registry.yarnpkg.com/@vue/component-compiler-utils/-/component-compiler-utils-2.1.2.tgz#75e7cc8496baecbb0994dc8783571d9ff07737fe"
@@ -5717,7 +5721,7 @@ scss-tokenizer@^0.2.3:
57175721
js-base64 "^2.1.8"
57185722
source-map "^0.4.2"
57195723

5720-
"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.5.0:
5724+
"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.3.0, semver@^5.5.0:
57215725
version "5.5.0"
57225726
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
57235727

@@ -6302,7 +6306,17 @@ tryer@^1.0.0:
63026306
version "1.0.1"
63036307
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
63046308

6305-
tslib@^1.9.0:
6309+
ts-loader@^4.4.2:
6310+
version "4.4.2"
6311+
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-4.4.2.tgz#778d4464b24436873c78f7f9e914d88194c2a248"
6312+
dependencies:
6313+
chalk "^2.3.0"
6314+
enhanced-resolve "^4.0.0"
6315+
loader-utils "^1.0.2"
6316+
micromatch "^3.1.4"
6317+
semver "^5.0.1"
6318+
6319+
tslib@^1.9.0, tslib@^1.9.3:
63066320
version "1.9.3"
63076321
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
63086322

@@ -6331,6 +6345,10 @@ typedarray@^0.0.6:
63316345
version "0.0.6"
63326346
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
63336347

6348+
typescript@^3.0.1:
6349+
version "3.0.1"
6350+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.1.tgz#43738f29585d3a87575520a4b93ab6026ef11fdb"
6351+
63346352
uglify-es@^3.3.4:
63356353
version "3.3.9"
63366354
resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677"
@@ -6562,6 +6580,10 @@ vue-template-es2015-compiler@^1.6.0:
65626580
version "1.6.0"
65636581
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.6.0.tgz#dc42697133302ce3017524356a6c61b7b69b4a18"
65646582

6583+
vue@^2.5.17:
6584+
version "2.5.17"
6585+
resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.17.tgz#0f8789ad718be68ca1872629832ed533589c6ada"
6586+
65656587
vuex@^3.0.1:
65666588
version "3.0.1"
65676589
resolved "https://registry.yarnpkg.com/vuex/-/vuex-3.0.1.tgz#e761352ebe0af537d4bb755a9b9dc4be3df7efd2"

0 commit comments

Comments
 (0)