From f6e33ead8fcbca9abdc3bbdaa50e9d3661f3f4e8 Mon Sep 17 00:00:00 2001 From: shitikakei Date: Wed, 18 Aug 2021 03:18:43 +0900 Subject: [PATCH] compliete --- .vscode/launch.json | 24 +++++++++++++ .vscode/settings.json | 31 ++++++++++++++++ .vscode/tasks.json | 17 +++++++++ Archive/sandbox.js | 28 +++++++++++++++ Archive/sandbox.ts | 44 +++++++++++++++++++++++ outDir/Archive/sandbox.js | 36 +++++++++++++++++++ outDir/Archive/sandbox.js.map | 1 + outDir/sandbox.js | 36 +++++++++++++++++++ outDir/sandbox.js.map | 1 + outDir/sandbox2.js | 22 ++++++++++++ outDir/sandbox2.js.map | 1 + package.json | 20 +++++++++++ sandbox2.ts | 28 +++++++++++++++ tsconfig.json | 68 +++++++++++++++++++++++++++++++++++ 14 files changed, 357 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json create mode 100644 Archive/sandbox.js create mode 100644 Archive/sandbox.ts create mode 100644 outDir/Archive/sandbox.js create mode 100644 outDir/Archive/sandbox.js.map create mode 100644 outDir/sandbox.js create mode 100644 outDir/sandbox.js.map create mode 100644 outDir/sandbox2.js create mode 100644 outDir/sandbox2.js.map create mode 100644 package.json create mode 100644 sandbox2.ts create mode 100644 tsconfig.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..428c7d8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // IntelliSense を使用して利用可能な属性を学べます。 + // 既存の属性の説明をホバーして表示します。 + // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "pwa-node", + "preLaunchTask": "build-ts", + "request": "launch", + "name": "Launch Program", + "skipFiles": [ + "/**" + ], + "program": "${file}", + // マップファイル対象外のコードのステップを省略します + "smartStep": true, + "outFiles": [ + "${workspaceFolder}/outDir/**/*.js" + ], + "internalConsoleOptions": "openOnSessionStart", + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f2e1218 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,31 @@ +{ + "yaml.customTags": [ + "!And", + "!And sequence", + "!If", + "!If sequence", + "!Not", + "!Not sequence", + "!Equals", + "!Equals sequence", + "!Or", + "!Or sequence", + "!FindInMap", + "!FindInMap sequence", + "!Base64", + "!Join", + "!Join sequence", + "!Cidr", + "!Ref", + "!Sub", + "!Sub sequence", + "!GetAtt", + "!GetAZs", + "!ImportValue", + "!ImportValue sequence", + "!Select", + "!Select sequence", + "!Split", + "!Split sequence" + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..e517153 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "typescript", + "label": "build-ts", + "tsconfig": "tsconfig.json", + "problemMatcher": [ + "$tsc" + ], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/Archive/sandbox.js b/Archive/sandbox.js new file mode 100644 index 0000000..5701860 --- /dev/null +++ b/Archive/sandbox.js @@ -0,0 +1,28 @@ +// arrays +var names = ['luigi', 'mario', 'yoshi']; +names.push('toad'); +// names.push(3); +// names[1] = 3; +var numbers = [10, 20, 12, 15]; +numbers.push(25); +// numbers.push('shaun'); +// numbers[0] = 'shaun'; +var mixed = ['ken', 4, 'chun-li', 8, 9]; +mixed.push('ryu'); +mixed.push(10); +mixed[0] = 3; +// objects +var ninja = { + name: 'mario', + belt: 'black', + age: 30 +}; +ninja.age = 40; +ninja.name = 'ryu'; +// ninja.age = '30'; +// ninja.skills = ['fighting', 'sneaking'] +ninja = { + name: 'yoshi', + belt: 'orange', + age: 40 +}; diff --git a/Archive/sandbox.ts b/Archive/sandbox.ts new file mode 100644 index 0000000..c02e229 --- /dev/null +++ b/Archive/sandbox.ts @@ -0,0 +1,44 @@ +// 型推論 + +// arrays +let names = ['luigi', 'mario', 'yoshi']; + +names.push('toad'); +console.log(names); +// names.push(3); +// names[1] = 3; + +let numbers = [10, 20, 12, 15,'test']; + +numbers.push(25); +console.log(numbers) +// numbers.push('shaun'); +// numbers[0] = 'shaun'; + +let mixed = ['ken', 4, 'chun-li', 8, 9]; + +mixed.push('ryu'); +mixed.push(10); +mixed[0] = 3; +console.log(mixed); + +// objects +let ninja = { + name: 'mario', + belt: 'black', + age: 30 +}; + +ninja.age = 40; +ninja.name = 'ryu'; +// ninja.age = '30'; +// ninja.skills = ['fighting', 'sneaking'] + +ninja = { + name: 'yoshi', + belt: 'orange', + age: 40, + // skills: ['running'], +}; + +console.log(ninja); \ No newline at end of file diff --git a/outDir/Archive/sandbox.js b/outDir/Archive/sandbox.js new file mode 100644 index 0000000..c744700 --- /dev/null +++ b/outDir/Archive/sandbox.js @@ -0,0 +1,36 @@ +"use strict"; +// 型推論 +// arrays +let names = ['luigi', 'mario', 'yoshi']; +names.push('toad'); +console.log(names); +// names.push(3); +// names[1] = 3; +let numbers = [10, 20, 12, 15, 'test']; +numbers.push(25); +console.log(numbers); +// numbers.push('shaun'); +// numbers[0] = 'shaun'; +let mixed = ['ken', 4, 'chun-li', 8, 9]; +mixed.push('ryu'); +mixed.push(10); +mixed[0] = 3; +console.log(mixed); +// objects +let ninja = { + name: 'mario', + belt: 'black', + age: 30 +}; +ninja.age = 40; +ninja.name = 'ryu'; +// ninja.age = '30'; +// ninja.skills = ['fighting', 'sneaking'] +ninja = { + name: 'yoshi', + belt: 'orange', + age: 40, + // skills: ['running'], +}; +console.log(ninja); +//# sourceMappingURL=sandbox.js.map \ No newline at end of file diff --git a/outDir/Archive/sandbox.js.map b/outDir/Archive/sandbox.js.map new file mode 100644 index 0000000..a2a0f89 --- /dev/null +++ b/outDir/Archive/sandbox.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../Archive/sandbox.ts"],"names":[],"mappings":";AAAA,MAAM;AAEN,SAAS;AACT,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAExC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACnB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACnB,iBAAiB;AACjB,gBAAgB;AAEhB,IAAI,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAC,MAAM,CAAC,CAAC;AAEtC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AACpB,yBAAyB;AACzB,wBAAwB;AAExB,IAAI,KAAK,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAExC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACf,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAEnB,UAAU;AACV,IAAI,KAAK,GAAG;IACV,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,GAAG,EAAE,EAAE;CACR,CAAC;AAEF,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;AACf,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC;AACnB,oBAAoB;AACpB,0CAA0C;AAE1C,KAAK,GAAG;IACN,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,EAAE;IACP,uBAAuB;CACxB,CAAC;AAEF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC"} \ No newline at end of file diff --git a/outDir/sandbox.js b/outDir/sandbox.js new file mode 100644 index 0000000..c744700 --- /dev/null +++ b/outDir/sandbox.js @@ -0,0 +1,36 @@ +"use strict"; +// 型推論 +// arrays +let names = ['luigi', 'mario', 'yoshi']; +names.push('toad'); +console.log(names); +// names.push(3); +// names[1] = 3; +let numbers = [10, 20, 12, 15, 'test']; +numbers.push(25); +console.log(numbers); +// numbers.push('shaun'); +// numbers[0] = 'shaun'; +let mixed = ['ken', 4, 'chun-li', 8, 9]; +mixed.push('ryu'); +mixed.push(10); +mixed[0] = 3; +console.log(mixed); +// objects +let ninja = { + name: 'mario', + belt: 'black', + age: 30 +}; +ninja.age = 40; +ninja.name = 'ryu'; +// ninja.age = '30'; +// ninja.skills = ['fighting', 'sneaking'] +ninja = { + name: 'yoshi', + belt: 'orange', + age: 40, + // skills: ['running'], +}; +console.log(ninja); +//# sourceMappingURL=sandbox.js.map \ No newline at end of file diff --git a/outDir/sandbox.js.map b/outDir/sandbox.js.map new file mode 100644 index 0000000..f73282a --- /dev/null +++ b/outDir/sandbox.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../sandbox.ts"],"names":[],"mappings":";AAAA,MAAM;AAEN,SAAS;AACT,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAExC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACnB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACnB,iBAAiB;AACjB,gBAAgB;AAEhB,IAAI,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAC,MAAM,CAAC,CAAC;AAEtC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AACpB,yBAAyB;AACzB,wBAAwB;AAExB,IAAI,KAAK,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAExC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACf,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAEnB,UAAU;AACV,IAAI,KAAK,GAAG;IACV,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,OAAO;IACb,GAAG,EAAE,EAAE;CACR,CAAC;AAEF,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;AACf,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC;AACnB,oBAAoB;AACpB,0CAA0C;AAE1C,KAAK,GAAG;IACN,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,EAAE;IACP,uBAAuB;CACxB,CAAC;AAEF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC"} \ No newline at end of file diff --git a/outDir/sandbox2.js b/outDir/sandbox2.js new file mode 100644 index 0000000..8d73520 --- /dev/null +++ b/outDir/sandbox2.js @@ -0,0 +1,22 @@ +"use strict"; +// 型指定をanyにすると普通の変数みたくTSでも型が変動する +let age = 25; +console.log(age); +age = true; +console.log(age); +age = "hello"; +console.log(age); +age = { name: "mario", test: 64 }; +console.log(age); +// ObjectやListは[]や{}で指定 +let listTest = []; +listTest.push(5); +listTest.push("human"); +listTest.push(false); +console.log(listTest); +let objectTest; +objectTest = { name: "mario", test: 64 }; +console.log(objectTest); +objectTest = { name: "yoshi", test: "SF" }; +console.log(objectTest); +//# sourceMappingURL=sandbox2.js.map \ No newline at end of file diff --git a/outDir/sandbox2.js.map b/outDir/sandbox2.js.map new file mode 100644 index 0000000..d1a2b36 --- /dev/null +++ b/outDir/sandbox2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sandbox2.js","sourceRoot":"","sources":["../sandbox2.ts"],"names":[],"mappings":";AAAA,gCAAgC;AAEhC,IAAI,GAAG,GAAQ,EAAE,CAAC;AAClB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjB,GAAG,GAAG,IAAI,CAAC;AACX,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACjB,GAAG,GAAG,OAAO,CAAC;AACd,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACjB,GAAG,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AAClC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjB,uBAAuB;AAEvB,IAAI,QAAQ,GAAU,EAAE,CAAC;AAEzB,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACvB,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEtB,IAAI,UAAoC,CAAC;AAEzC,UAAU,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AACzC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAExB,UAAU,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC3C,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..e708253 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "typescript-tutorial", + "version": "1.0.0", + "description": "", + "main": "sandbox.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/iamshaunjp/typescript-tutorial.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/iamshaunjp/typescript-tutorial/issues" + }, + "homepage": "https://github.com/iamshaunjp/typescript-tutorial#readme" +} diff --git a/sandbox2.ts b/sandbox2.ts new file mode 100644 index 0000000..64db6da --- /dev/null +++ b/sandbox2.ts @@ -0,0 +1,28 @@ +// 型指定をanyにすると普通の変数みたくTSでも型が変動する + +let age: any = 25; +console.log(age); + +age = true; +console.log(age); +age = "hello"; +console.log(age); +age = { name: "mario", test: 64 }; +console.log(age); + +// ObjectやListは[]や{}で指定 + +let listTest: any[] = []; + +listTest.push(5); +listTest.push("human"); +listTest.push(false); +console.log(listTest); + +let objectTest: { name: any; test: any }; + +objectTest = { name: "mario", test: 64 }; +console.log(objectTest); + +objectTest = { name: "yoshi", test: "SF" }; +console.log(objectTest); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..5c53f0e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,68 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ + "target": "es2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */ + "module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ + "lib": [ + "es2020", + "dom" + ], /* Specify library files to be included in the compilation. */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + "outDir": "./outDir/", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "composite": true, /* Enable project compilation */ + // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + /* Source Map Options */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + /* Advanced Options */ + "skipLibCheck": true, /* Skip type checking of declaration files. */ + "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + } +} \ No newline at end of file