GithubHelp home page GithubHelp logo

yfain / getts Goto Github PK

View Code? Open in Web Editor NEW
123.0 123.0 66.0 18.93 MB

Code samples for the book TypeScript Quickly

License: MIT License

TypeScript 69.28% HTML 8.59% CSS 11.47% JavaScript 3.82% Vue 6.84%

getts's People

Contributors

antonmoiseev avatar yfain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

getts's Issues

Chapter 12: ng-client errors

@yfain Errors!


> [email protected] start
> ng serve

(node:1350155) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2022-03-19T20:33:00.049Z
Hash: 19cdfdec1a616ee8cce4
Time: 5875ms
chunk {es2015-polyfills} es2015-polyfills.js, es2015-polyfills.js.map (es2015-polyfills) 285 kB [initial] [rendered]
chunk {main} main.js, main.js.map (main) 46.4 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 236 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 19.3 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.8 MB [initial] [rendered]

ERROR in ./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Cannot find module 'node-sass'
Require stack:
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/sass-loader/lib/loader.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/loader-runner/lib/loadLoader.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/loader-runner/lib/LoaderRunner.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/webpack/lib/NormalModule.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/webpack/lib/NormalModuleFactory.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/webpack/lib/Compiler.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/webpack/lib/webpack.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular-devkit/build-webpack/src/webpack/index.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular-devkit/build-webpack/src/index.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular-devkit/build-angular/src/dev-server/index.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular-devkit/architect/src/architect-legacy.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular-devkit/architect/src/index.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular/cli/models/architect-command.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular/cli/commands/build-impl.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular-devkit/schematics/tools/export-ref.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular-devkit/schematics/tools/index.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular/cli/utilities/json-schema.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular/cli/models/command-runner.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular/cli/lib/cli/index.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular/cli/lib/init.js
- ~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/@angular/cli/bin/ng
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.sassLoader (~/Documents/WorkspaceJavaScript/forks/getts/chapter12/client/node_modules/sass-loader/lib/loader.js:46:72)

Chapter 9 - how to import other TypeScript modules?

In the example in Chapter 9, a third-party JavaScript module is imported (reused) in the TypeScript.

What about when you want to make your own separate modules in TypeScript?

I tried to extend the Chapter 9 code with a src/browser/a.ts class that is simply

export class A { /* ... */ }

VS Code wants to import A using classic TypeScript syntax (just after the blockchain elements are imported):

import { Blockchain, Block } from '../lib/bc_transactions.js';
import { A } from 'a';

But when I run the code, I get a errors for importing a -- first it requires a relative URL (so, I make it ./a but then I get an error saying it's looking for a.js).

Is there a clean solution in Chapter 9 for using TypeScript modules? It hardly feels realistic if all of the project is in main.ts.

In the mean time, rather than using a bundler, I'll follow the advice of specifying .js at the end of the import's specification microsoft/TypeScript#27287 (comment)

Wrong Chapter 2.1: Listing 2.5 code none return value

Error Source:

function calcTax(state: string, income: number, dependents: number) : number { 1

    if (state === 'NY'){
        return income * 0.06 - dependents * 500;
    } else if (state ==='NJ'){
        return income * 0.05 - dependents * 300;
    }
}

1 The function arguments and its **return value** have type annotations.

The correct way is...

function calcTax(state: string, income: number, dependents: number) : number {

    if (state === 'NY'){
        return income * 0.06 - dependents * 500;
    } else if (state ==='NJ'){
        return income * 0.05 - dependents * 300;
    }
    return 0; // !!!!
}

Fix warning chapter 15: Router Product List

Warnings now

`WARNING in ~/router-product-list/src/product.ts
5:4 trailing whitespace
3 | title: string;
4 | price: number;

5 | }
| ^
WARNING in ~/router-product-list/src/product.ts
5:6 file should end with a newline
3 | title: string;
4 | price: number;
5 | }
| ^
WARNING in ~/router-product-list/src/views/Home.vue
39:3 The class property 'products' must be marked either 'private', 'public', or 'protected'
37 | export default class Home extends Vue {
38 |
39 | products: Product[]=[];
| ^
40 |
41 | selectedProduct: Product | null= null;
42 |
WARNING in ~/router-product-list/src/views/Home.vue
39:22 missing whitespace
37 | export default class Home extends Vue {
38 |
39 | products: Product[]=[];
| ^
40 |
41 | selectedProduct: Product | null= null;
42 |
WARNING in ~/router-product-list/src/views/Home.vue
39:23 missing whitespace
37 | export default class Home extends Vue {
38 |
39 | products: Product[]=[];
| ^
40 |
41 | selectedProduct: Product | null= null;
42 |
WARNING in ~/router-product-list/src/views/Home.vue
41:3 The class property 'selectedProduct' must be marked either 'private', 'public', or 'protected'
39 | products: Product[]=[];
40 |
41 | selectedProduct: Product | null= null;
| ^
42 |
43 | created() {
44 | fetch("/products.json")
WARNING in ~/router-product-list/src/views/Home.vue
41:34 missing whitespace
39 | products: Product[]=[];
40 |
41 | selectedProduct: Product | null= null;
| ^
42 |
43 | created() {
44 | fetch("/products.json")
WARNING in ~/router-product-list/src/views/Home.vue
43:3 The class method 'created' must be marked either 'private', 'public', or 'protected'
41 | selectedProduct: Product | null= null;
42 |
43 | created() {
| ^
44 | fetch("/products.json")
45 | .then(response => response.json())
46 | .then(json => {
WARNING in ~/router-product-list/src/views/Home.vue
44:11 " should be '
42 |
43 | created() {
44 | fetch("/products.json")
| ^
45 | .then(response => response.json())
46 | .then(json => {
47 | this.products=json;
WARNING in ~/router-product-list/src/views/Home.vue
45:11 Parentheses are required around the parameters of an arrow function definition
43 | created() {
44 | fetch("/products.json")
45 | .then(response => response.json())
| ^
46 | .then(json => {
47 | this.products=json;
48 | },
WARNING in ~/router-product-list/src/views/Home.vue
46:11 Parentheses are required around the parameters of an arrow function definition
44 | fetch("/products.json")
45 | .then(response => response.json())
46 | .then(json => {
| ^
47 | this.products=json;
48 | },
49 | (error) => {
WARNING in ~/router-product-list/src/views/Home.vue
47:20 missing whitespace
45 | .then(response => response.json())
46 | .then(json => {
47 | this.products=json;
| ^
48 | },
49 | (error) => {
50 | console.log('Error loading products.json:', error);
WARNING in ~/router-product-list/src/views/Home.vue
47:21 missing whitespace
45 | .then(response => response.json())
46 | .then(json => {
47 | this.products=json;
| ^
48 | },
49 | (error) => {
50 | console.log('Error loading products.json:', error);
WARNING in ~/router-product-list/src/views/Home.vue
50:8 Calls to 'console.log' are not allowed.
48 | },
49 | (error) => {
50 | console.log('Error loading products.json:', error);
| ^
51 | });
52 | }
53 |
No type errors found
Version: typescript 3.9.10, tslint 5.20.1`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.