question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No compile errors

See original GitHub issue

I using ts-nameof to reduce the number of petiential bug that string can cause when using class or interface prop names. It work great in general but if I type the wrong prop name then it compile without any errors. Am I doing someting wrong or it’s something that you can’t manage?

I tried both babel typescript and babel macros ways to compile and both do the same behavior, no error caught. I’m working on a new NextJs project.

node version: 14.16.0

tsconfig.json

{
  "compilerOptions": {
    "target": "ES6",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve"
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"]
}

packages.json

{
  "$schema": "https://json.schemastore.org/package",
  "name": "my-project",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "dev": "cross-env NODE_OPTIONS='--inspect' next dev",
    "build": "next build",
    "start": "next start",
  },
  "dependencies": {
    "@microsoft/applicationinsights-web": "^2.5.11",
    "@types/ts-nameof": "^4.2.1",
    "babel-plugin-ts-nameof": "^4.2.1",
    "google-libphonenumber": "^3.2.18",
    "lodash": "^4.17.21",
    "next": "^10.0.8",
    "next-seo": "^4.20.0",
    "next-translate": "^1.0.4",
    "react": "^17.0.1",
    "react-bootstrap": "0.33.1",
    "react-dom": "^17.0.1",
    "react-query": "^3.12.1",
    "yup": "^0.32.9"
  },
  "devDependencies": {
    "@babel/cli": "^7.13.10",
    "@babel/preset-env": "^7.13.10",
    "@types/google-libphonenumber": "^7.4.19",
    "@types/lodash": "^4.14.168",
    "@types/node": "^14.14.34",
    "@types/preval.macro": "^3.0.0",
    "@types/react": "^17.0.3",
    "@types/react-bootstrap": "^0.32.25",
    "@types/react-query": "^1.1.2",
    "@typescript-eslint/eslint-plugin": "^4.17.0",
    "@typescript-eslint/parser": "^4.17.0",
    "autoprefixer": "^10.2.5",
    "babel-plugin-lodash": "^3.3.4",
    "babel-plugin-macros": "^3.0.1",
    "cross-env": "^7.0.3",
    "eslint": "^7.22.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-react": "^7.22.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "postcss": "^8.2.8",
    "prettier": "^2.2.1",
    "preval.macro": "^5.0.0",
    "tailwindcss": "^2.0.3",
    "typescript": "^4.2.3"
  },
  "babel": {
    "presets": [
      "next/babel"
    ],
    "plugins": [
      "babel-plugin-macros",
      "babel-plugin-ts-nameof",
      "lodash"
    ]
  },
  "eslintConfig": {
    "env": {
      "browser": true,
      "es6": true,
      "node": true
    },
    "extends": [
      "eslint:recommended",
      "plugin:@typescript-eslint/recommended",
      "plugin:react/recommended",
      "plugin:react-hooks/recommended",
      "plugin:jsx-a11y/recommended",
      "plugin:prettier/recommended"
    ],
    "overrides": [
      {
        "files": [
          "**/*.ts",
          "**/*.tsx"
        ]
      }
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
      "ecmaVersion": 2020
    },
    "rules": {
      "react/prop-types": "off",
      "react/react-in-jsx-scope": "off",
      "jsx-a11y/anchor-is-valid": "off",
      "@typescript-eslint/no-unused-vars": [
        "error",
        {
          "argsIgnorePattern": "^_"
        }
      ],
      "@typescript-eslint/explicit-function-return-type": [
        "warn",
        {
          "allowExpressions": true,
          "allowConciseArrowFunctionExpressionsStartingWithVoid": true
        }
      ]
    },
    "settings": {
      "react": {
        "version": "detect"
      }
    }
  },
  "prettier": {
    "arrowParens": "always",
    "endOfLine": "lf",
    "jsxBracketSameLine": true,
    "printWidth": 256,
    "singleQuote": true,
    "tabWidth": 2
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dsherretcommented, Mar 17, 2021

@sebascomeau you may want to create a separate type that doesn’t have the index type.

interface TypeWithOnlyProperties {
    prop: string;
}

interface TypeWithEverything extends TypeWithOnlyProperties {
    [key: string]: string | undefined;
}

nameof<TypeWithOnlyProperties>(o => o.otherProp); // error
0reactions
sebascomeaucommented, Mar 17, 2021

Thanks for the tips. I will do that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is there no compilation error? - c++ - Stack Overflow
When i am compiling the code below,it is running without any errors. #include<stdio.h> struct adjacency { struct ...
Read more >
Why do I get a "All compiler errors have to be fixed before you ...
When trying to enter Play mode, I receive the error "All compiler errors have to be fixed before entering playmode!". Cause: If any...
Read more >
7.3. Compile Errors and Warnings
A compile error happens when the compiler reports something wrong with your program, and does not produce a machine-language translation.
Read more >
c# Compile errors not showing in ErrorList
The project fails to compile, but I see no errors in the Error List, I can only see the compilation problems in the...
Read more >
Fix the top 10 most common compile time errors in Java
This Java class must be saved in a file named ThisWillCompile.java -- or else it won't compile. Java provides no lenience here --...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found